/*
 * File:   Neumaier3.h
 * Author: jcrada
 *
 * Created on 11 April 2011, 10:40 AM
 */

#ifndef ECB_NEUMAIER3_H
#define	ECB_NEUMAIER3_H

#include "ecb/base/Problem.h"

namespace ecb {

    /* Source:
     * @incollection{springer-dif.evo,
      Author = {Price, Kenneth and Storn, Rainer M. and Lampinen, Jouni A.},
      title={{Appendix}},
      booktitle = {Differential Evolution: A Practical Approach to Global Optimization},
      series={Natural Computing Series},
      editor={Rozenberg, G. and Bäck, Th. and Eiben, A. E. and Kok, J. N. and Spaink, H. P.},
      publisher = {Springer-Verlag Berlin Heidelberg},
      pages = {513-533},
      year = {2005}
      }
     */

    class Neumaier3 : public Problem {
    public:
        //minimum = -dimensions*dimensions
        //maximum = dimensions*dimensions

        Neumaier3(const std::string& id = "Neumaier3", const std::string& name = "Neumaier3",
                int dimensions = 0, scalar minimum = -INFINITY, scalar maximum = INFINITY,
                bool minimization = true) :
        Problem(id, name, dimensions, minimum, maximum, minimization) { }

        scalar f(const std::vector<scalar>& x) {
            scalar sum_a, sum_b = 0;
            for (size_t i = 0; i < x.size(); ++i) {
                sum_a += (x[i] - 1) * (x[i] - 1);
                if (i > 0) {
                    sum_b += x[i - 1] * x[i];
                }
            }
            return sum_a - sum_b;
        }
    };
}

#endif	/* PSO_NEUMAIER3_H */

